package com.hp.controller.api;

import com.hp.entity.Message;
import com.hp.result.ResultInfo;
import com.hp.service.MessageService;
import com.hp.utils.WeatherUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/message")
public class ApiMessageController {


    @Autowired
    private MessageService messageService;
    /**
     * 添加留言板
     *
     * @param message
     * @return
     */
    @RequestMapping(value = "addmessage", method = RequestMethod.POST)
    public ResultInfo addmessage(Message message) throws Exception {
        messageService.addmessage(message);
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setType(1);
        resultInfo.setMessageCode(200);
        resultInfo.setMessage("ok");
        return resultInfo;
    }

    @RequestMapping(value = "getAllmessage")
    public ResultInfo getAllmessage() throws Exception {
        List<Message> mss = messageService.findAllByIsY();
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setType(1);
        resultInfo.setMessageCode(200);
        resultInfo.setMessage("ok");
        resultInfo.getSysdata().put("mss", mss);
        return resultInfo;
    }

}
